package dom.xpath.core;


/**
 * This class assembles properties which are used all around the
 * project. They are initially read from and finally written to disk.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-07, ISC License
 * @author Christian Gruen
 */
public final class Prop {
  
  // STATIC PROPERTIES ========================================================

  /** Returns the system's default encoding. */
  public static final String ENCODING = System.getProperty("file.encoding");
  /** Returns the current working directory. */
  public static final String WORK = System.getProperty("user.dir") + "/";
  /** User's home directory. */
  public static final String HOME = System.getProperty("user.home");
  /** Flag denoting if OS belongs to UNIX or Windows family. */
  public static final boolean UNIX =
    System.getProperty("os.name").charAt(0) != 'W';
  /** New line string. */
  public static final String NL = System.getProperty("line.separator");

  // DATABASE & PROGRAM PATHS =================================================
  
  /** Database path. */
  public static String dbpath = HOME + "/BaseXData";
  /** Path to pathfinder. */
  public static String pathfinder = "pf";
  /** Path to dotty. */
  public static String dotty = "dotty";

  // TRANSIENT OPTIONS ========================================================
  
  /** The following options are not saved/read; don't remove this flag. */
  public static final boolean SKIP = true;

  /** Debug mode. */
  public static boolean debug = false;
  /** Short query info. */
  public static boolean info = false;
  /** Detailed query info. */
  public static boolean allInfo = false;
  /** Flag for serializing query results. */
  public static boolean serialize = true;
  /** Flag for serialization as XML. */
  public static boolean xmloutput = false;
  /** Format XQuery output. */
  public static boolean xqformat = true;

  /** Number of query executions. */
  public static int runs = 1;
  /** Flag for whitespace chopping. */
  public static boolean chop = false;
  /** Flag for entity parsing. */
  public static boolean entity = true;
  /** Flag for creating a word index. */
  public static boolean wordindex = false;
  /** Flag for creating a fulltext index. */
  public static boolean ftindex = false;
  /** Flag for creating a text index. */
  public static boolean textindex = true;
  /** Flag for creating an attribute value index. */
  public static boolean attrindex = true;
  /** Flag for loading database table into main memory. */
  public static boolean mainmem = false;
  /** Flag for creating databases on-the-fly (in memory). */
  public static boolean onthefly = false;
  /** Flow for showing the XQuery error code. */
  public static boolean xqerrcode = true;

  // FILE SYSTEM OPTIONS ======================================================
  
  /** Flag for creating fs stat info. */
  public static boolean fsstat = false;
  /** Flag for importing file contents. */
  public static boolean fscont = false;
  /** Flag for importing file metadata. */
  public static boolean fsmeta = false;
  /** Maximum size for textual imports. */
  public static int fstextmax = 10240;

  // PATHFINDER OPTIONS (-d flag must be specified to activate dumps) =========

  /** Show executed operators. */
  public static boolean pfOp = true;
  /** Print XML Query plan. */
  public static boolean pfXML = true;
  /** Dots the Query plan. */
  public static boolean pfDAG = true;
  
  // CONFIG OPTIONS ===========================================================

  /** Default path to the BaseX configuration file. */
//  private static final String CONFIGFILE = HOME + "/.basex";
  /** Remembers if the config file has already been read. */
//  private static boolean read;

  /** Private constructor, preventing class instantiation. */
  private Prop() { }


  /**
   * Sets some (temporary) pathfinder debug modes.
   * @param d debug value
   */
  public static void pf(final int d) {
    if(d == Integer.MIN_VALUE) return;
    pfOp      = (d & 1) != 0;
    pfXML     = (d & 2) != 0;
    pfDAG     = (d & 4) != 0;
    debug = true;
  }
}
